package com.iot.comprehensive.face.service.impl;

import com.iot.comprehensive.face.dao.AccessFormDao;
import com.iot.comprehensive.face.model.AccessForm;
import com.iot.comprehensive.face.service.AccessFormService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author 朱泽玉
 * @Create 2021/6/27 16:59
 * @Description
 * @Modified By:
 */
@Service
public class AccessFormServiceImpl implements AccessFormService {
    final AccessFormDao accessFormDao;

    public AccessFormServiceImpl(AccessFormDao accessFormDao) {
        this.accessFormDao = accessFormDao;
    }

    @Override
    public void add(AccessForm accessForm) {
        System.out.println(accessForm);
        accessFormDao.save(accessForm);
    }

    @Override
    public void update(AccessForm accessFormNew) {
        this.add(accessFormNew);
    }

    @Override
    public List<AccessForm> findAll() {
        return accessFormDao.findAll();
    }

    @Override
    public AccessForm findById(int id) {
        return accessFormDao.findById(id).orElse(null);
    }

    @Override
    public List<AccessForm> findByUserId(Long account_id) {
        return accessFormDao.findByUserId(account_id);
    }

    @Override
    public List<AccessForm> findByAdminId(Long account_id) {
        return accessFormDao.findByAdminId(account_id);
    }

    @Override
    public List<AccessForm> findByHostId(Long account_id) {
        return accessFormDao.findByHostId(account_id);
    }

    @Override
    public void del(int id) {
        accessFormDao.deleteById(id);
    }

    @Override
    public List<AccessForm> findAvailable(Long account_id) {
        return accessFormDao.findAvailable(account_id);
    }
}
